package com.seecen.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.seecen.mapper.CuisineMainCategoriesMapper;
import com.seecen.pojo.CuisineMainCategories;
import com.seecen.service.CuisineMainCategoriesService;
import com.seecen.utils.Result;
import com.seecen.utils.ResultCodeEnum;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 19811
* @description 针对表【t_cuisine_main_categories(菜谱分类大类表)】的数据库操作Service实现
* @createDate 2025-07-22 09:54:27
*/
@Service
public class CuisineMainCategoriesServiceImpl extends ServiceImpl<CuisineMainCategoriesMapper, CuisineMainCategories>
    implements CuisineMainCategoriesService{

    //查找所有子分类
    @Override
    public Result findAllWithSubCategories() {
        try {
            List<CuisineMainCategories> categories = baseMapper.selectAllWithSubCategories();
            return Result.ok(categories); // 使用统一的成功返回
        } catch (Exception e) {
            log.error("查询分类数据失败", e);
            return Result.build(null, ResultCodeEnum.SYSTEM_ERROR);
        }
    }
}




